<?php


declare(strict_types=1);

/**
 * WxuserController.php
 * 微信用户管理后台
 * User：Abell
 * Date：2020/4/15
 * Time：18:11
 */

namespace App\Controller\Admin;

use App\Controller\AbstractController;
use Hyperf\HttpServer\Contract\RequestInterface;
use Hyperf\Di\Annotation\Inject;
use App\Service\WxuserService;
use App\Validate\WxuserValidation;

class WxuserController extends AbstractController
{
    /**
     * @Inject
     * @var WxuserService
     */
    protected $service;

    /**
     * 用户全国地图
     * @Author abell
     * @DateTime 2020-05-28
     * @param array $request
     * @return
     */
    public function mapUsers(RequestInterface $request){
        return $this->jsonApi($this->service->mapInfo());
    }

    /**
     * 用户列表
     * @Author abell
     * @DateTime 2020-05-28
     * @param array $request
     * @return
     */
    public function userList(RequestInterface $request){
        return $this->jsonApi($this->service->userList($request->all()));
    }

    /**
     * 用户信息编辑
     * @Author abell
     * @DateTime 2020-05-28
     * @param array $request
     * @return object
     */
    public function userEdit(RequestInterface $request){
        make(WxuserValidation::class)->check($request->all(),'admin_edit')->response();
        if($request->isMethod('get')){
            return $this->jsonApi($this->service->userEditInfo($request->all()));
        }else{
            return $this->jsonApi($this->service->userEditSave($request->all()));
        }
    }
}